import { createRouter, createWebHashHistory } from 'vue-router'
export const Layout = () => import('@renderer/layouts/index.vue')
const constantRoutes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@renderer/views/login/index.vue'),
    meta: { hidden: true }
  }
]
export const routes = [
  {
    path: '/',
    component: Layout,
    meta: { hidden: true, title: '首页' },
    redirect: '/main',
    children: [
      {
        path: 'main',
        name: 'main',
        component: () => import('../views/main/index.vue'),
        meta: {
          title: '首页',
          icon: 'dianshiju'
        }
      }
    ]
  },
  {
    path: '/tools',
    component: Layout,
    meta: { hidden: true, title: '工具箱' },
    redirect: '/vuex',
    children: [
      {
        path: 'vuex',
        name: 'vuex',
        component: () => import('../views/tools/vuexGenerateTools/index.vue'),
        meta: {
          title: 'vuex快捷生成工具',
          icon: 'dongwu'
        }
      },
      {
        path: 'projectControl',
        name: 'projectControl',
        component: () => import('../views/tools/projectControl/index.vue'),
        meta: {
          title: '项目管理工具',
          icon: 'gongyi'
        }
      },
      {
        path: 'writeToI18n',
        name: 'writeToI18n',
        component: () => import('../views/tools/writeToI18nFile/index.vue'),
        meta: {
          title: 'i18n写入工具',
          icon: 'guixu'
        }
      }
    ]
  },
  {
    path: '/plugins',
    component: Layout,
    meta: { hidden: true, title: '插件' },
    redirect: '/vChartIM',
    children: [
      {
        path: 'vChartIM',
        name: 'vChartIM',
        component: () => import('../views/plugins/vChatIM/index.vue'),
        meta: {
          title: 'im插件开发',
          icon: 'guochuang'
        }
      },
      {
        path: 'terminal',
        name: 'terminal',
        component: () => import('../views/plugins/terminal/index.vue'),
        meta: {
          title: 'terminal插件开发',
          icon: 'huihua'
        }
      },
      {
        path: 'screenRecording',
        name: 'screenRecording',
        component: () => import('../views/plugins/screenRecording/index.vue'),
        meta: {
          title: '录屏插件开发',
          icon: 'huodong'
        }
      },
      {
        path: 'AreaSelectView',
        name: 'AreaSelectView',
        component: () => import('../views/plugins/screenRecording/AreaSelectView.vue'),
        meta: {
          title: '录屏插件',
          icon: 'huwaichaoliu'
        }
      }
    ]
  }
]
const router = createRouter({
  history: createWebHashHistory(),
  routes: [...routes, ...constantRoutes],
  // 刷新时，滚动条位置还原
  scrollBehavior: () => ({ left: 0, top: 0 })
})
export function setupRouter(app) {
  app.use(router)
}
export default router
